using System.Collections;
using System.Collections.Generic;
using MemoryPack;
using TMPro;
using UnityEngine;
using UnityEngine.UI;

public class LoginView : MonoBehaviour
{
    public TMP_InputField username;
    public TMP_InputField password;
    public Button loginButton;
    
    void Awake()
    {
        loginButton.onClick.AddListener(OnLoginClick);
    }

    private void OnLoginClick()
    {
        if (username.text == "" && password.text == "")
        {
            return;
        }
        Account account = new Account();
        account.username = username.text;
        account.password = password.text;
        //序列化
        byte[] bytes = MemoryPackSerializer.Serialize(account);
        GlobalManager.Instance.clientSocket.OnSendData(bytes);
    }
    

}

[MemoryPackable]
public partial class Account
{
    public string username;
    public string password;
}

[MemoryPackable]
public partial class AccountResult
{
    public int result;
    public string msg;
}
